//测试mysql接口
//主路由
let express = require("express"); //绝对路径
// let query = require("../db/mysql");
//引入子路由
let userRouter = require("./modules/users"); //用户管理子路由
let uploadRouter = require("./modules/upload");
let goodRouter = require("./modules/goods");

//创建路由对象
let Router = express.Router(); //Router==app

Router.use(express.urlencoded()); //处理name=马源123&age=18
Router.use(express.json()); //处理json数据  '{name:王祖贤,age:18}'

// let sql = "SELECT * FROM user_inf WHERE name='malin'";
// query(sql, (result) => {
//   console.log(result);
// });

//测试
// let sql = "SELECT * FROM user_inf2 WHERE name='malin'";
// let p = query(sql);
// p.then((res) => {
//   console.log(res, "成功的数据"); // [{},{}]
// }).catch((err) => {
//   console.log(err, "错误");
// });
// console.log(p);

Router.use("/user", userRouter); //用户管理子路由
Router.use("/upload", uploadRouter); //用户管理子路由
Router.use("/good", goodRouter); //用户管理子路由

module.exports = Router; //导出主路由
